<template>
    <dv-border-box-2 ref="dvBox" style="width:100%;height:30vh;">
        <div class="table" style="height:100%;">
            <dv-scroll-board :config="config" style="height:100%;" />
        </div>
    </dv-border-box-2>
</template>  
  
<script setup>
import { ref, reactive, onMounted, nextTick, inject, watch } from 'vue';
const wsState = inject('wsState');
const dvBox = ref();
const config = reactive({
    header: ['姓名', '楼号', '进出时间', '状态'],
    data: wsState.table,
    rowNum: 5,
    headerHeight: 50,
    headerBGC: '#0f1325',
    oddRowBGC: '#0f1325',
    evenRowBGC: '#171c33',
    columnWidth: [100],
    align: ['center'],
    scroll: {
        speed: 2000, // 每2秒滚动一行
        rowNum: 5    // 可见行数
    }
})
watch(() => wsState.table, (val) => {
    config.data = val
})
onMounted(() => {
    setTimeout(() => {
        if (dvBox.value) {
            nextTick(() => {
                dvBox.value.initWH();
            })
        }
    })
})
</script>  
  
<style scoped lang="scss">
.dv-scroll-board * {
    font-size: 1.2vw;
    line-height: 1.5;
    height: auto;
}

.table {
    width: 100%;
    height: 30vh;
    min-height: 200px;
}
</style>